package com.web.surf.sample.eshop.database.manager.services;

import javax.faces.event.ActionEvent;
import com.web.surf.sample.eshop.database.dao.interfaces.IImagesDao;
import com.web.surf.sample.eshop.database.dao.services.ImageDaoImpl;
import com.web.surf.sample.eshop.database.manager.interfaces.IImagesService;
import com.web.surf.sample.eshop.faces.managed.beans.ImageDB;

public class ImagesServiceImpl implements IImagesService{

	private IImagesDao imagesDao= new ImageDaoImpl();
	private String fileName;
	private String imageID;
	private String imageName;
	
	
	public ImageDB getImageByID(String imageID) {		
		return imagesDao.getImageByID(imageID);
	}

	public void setImageIntoDB(String fileName) {
		imagesDao.setImageIntoDB(fileName);
	}	
	
	public ImageDB getImageByGoodsID(int goodsID) {		
		return imagesDao.getImageByGoodsID(goodsID);
	}	
	
	public void insertImage(ActionEvent a) {
		setImageIntoDB(fileName);
	}
	
	public void retrieveImage(ActionEvent a) {
		ImageDB im = getImageByID(imageID);
		imageName = im.getName();
	}
	
	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}	
	
	public String getImageName() {
		return imageName;
	}

	public void setImageName(String imageName) {
		this.imageName = imageName;
	}

	public String getImageID() {
		return imageID;
	}

	public void setImageID(String imageID) {
		this.imageID = imageID;
	}

	//Spring
	public void setImagesDao(IImagesDao imagesDao) {
		this.imagesDao = imagesDao;
	}



}
